package com.lun.blog.repostory;

import com.lun.blog.pojo.Message;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;

import java.util.List;

/**
 * @Function : MessageRespority
 * @Description:
 * @Param:
 * @version: v1.0.0
 * @author: fanglj5
 * @date : 2021/3/13
 * Modification History:
 * Date Author Version Description
 * -------------------------------------------------------------
 * 时间 作者 版本号 修改原因
 */
public interface MessageRepository  extends JpaRepository<Message,Long>, JpaSpecificationExecutor<Message> {

    List<Message> findByState(String state);

    List<Message> findByIdIn(List<Long> parentIdList);

    @Query(value = "SELECT * FROM t_message WHERE state='2' AND parent_message_id IS NULL ORDER BY create_time DESC ",nativeQuery = true)
    List<Message> findMessage();

    long count();

    List<Message> findByParentMessage_Id(Long parentId);
}
